Refine handling of OrderBookDeltas #3438
Open
+1,494
−90
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request
NautilusTrader prioritizes correctness and reliability, please follow existing patterns for validation and testing.
CONTRIBUTING.mdand followed the established practicesSummary
Summary
OrderBookDeltasacross the platform, improving support for historical data requests and on-the-fly backtesting.to_deltasin the RustOrderBookmodel to allow capturing the current book state as a series of deltas (a snapshot).request_order_book_deltasto theActorand updated subscription methods to support snapshot intervals viainterval_ms.DataEnginewith filtering logic for historicalOrderBookDeltas, including the ability to replay deltas from the start of a UTC day to evolve a snapshot to a specific start time.Changes
crates/model/src/orderbook/book.rs: Addedto_deltasto convert current book state to anOrderBookDeltassnapshot.nautilus_trader/common/actor.pyx: Addedrequest_order_book_deltasand updatedsubscribe_order_bookto supportinterval_ms.nautilus_trader/data/engine.pyx: Implemented_filter_historical_order_book_deltasfor snapshot evolution and date range filtering.nautilus_trader/data/messages.pyx: AddedRequestOrderBookDeltasand updatedSubscribeOrderBook.to_request.crates/adapters/databento: Added support for historical order book deltas in the Databento historical client.tests/: Added unit tests for the data engine and messages, and an acceptance test for order book deltas in backtests.Test plan
tests/unit_tests/data/test_engine.pyandtests/unit_tests/data/test_messages.py.tests/acceptance_tests/test_backtest.py.examples/backtest/notebooks/databento_test_order_book_deltas.py.Related Issues/PRs
Type of change
Breaking change details (if applicable)
Documentation
docs/developer_guide/docs.md)Release notes
RELEASES.mdthat follows the existing conventions (when applicable)Testing
Ensure new or changed logic is covered by tests.